package com.ssm.controller;

import com.ssm.entity.Role;
import com.ssm.service.RoleServiceI;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/rc")
public class RoleController extends BaseController{

    @Resource(name="roleServiceI")
    private RoleServiceI rsi;

    @RequestMapping("/index")
    public String index(){
        return prefix + "/role/index" + suffix;
    }

    @RequestMapping("/find")
    @ResponseBody
    public List<Role> find(Role role){
        return rsi.find(role);
    }

    @RequestMapping("/grantRole")
    @ResponseBody
    public Map<String,Object> grant(@Param(value = "mids") String mids,
                                    @Param(value = "rid") int rid){
        return rsi.grant(mids,rid);
    }

    @RequestMapping("/findRoleMenu")
    @ResponseBody
    public List<Integer> findRoleMenu(@Param(value = "rid") int rid){
        return rsi.findRoleMenu(rid);
    }

}
